package com.tutorial.springboot.document.init;

import com.tutorial.springboot.document.Post;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Component;

/**
 * Created by louchen on 2016/11/23.
 */
@Component
public class InitDocument implements InitializingBean {

    @Autowired
    private ElasticsearchTemplate elasticsearchTemplate;

    /**
     * 在此处完成映射
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        elasticsearchTemplate.putMapping(Post.class);
    }

}
